<?php
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="robots" content="index,follow" />
<?php
include_once("../includes/config.php");
?>
<link href="<?php echo $baseurl; ?>default.css" rel="stylesheet" title="Feuille de style principale" type="text/css" media="screen" />
<title>Transformation de texte</title>
<?php
if($_GET['phrase'])
{
$phrase = $_GET['phrase'];
}
else{
?>
	<script type="text/javascript" src="../libs/mootools.js"></script>
	<script type="text/javascript">
		window.addEvent('domready', function(){
			$('form').addEvent('submit', function(e) {
				/**
				 * Prevent the submit event
				 */
				new Event(e).stop();
			
				/**
				 * This empties the log and shows the spinning indicator
				 */
				var log = $('log_res').empty().addClass('ajax-loading');
			
				/**
				 * send takes care of encoding and returns the Ajax instance.
				 * onComplete removes the spinner from the log.
				 */
				this.send({
					encoding: 'uft-8',
					update: log,
					onComplete: function() {
						log.removeClass('ajax-loading');
					}
				});
			});
		});
		
	
	
	
if(!window.clipboardData) {
    window.clipboardData = {
        setData : function(mode,content) {
            var clipboard = document.body;
            var flashclipboard = clipboard.flashclipboard;
            if(flashclipboard == null) {
                flashclipboard = document.createElement('div');
                clipboard.flashclipboard = flashclipboard;
                clipboard.appendChild(flashclipboard);
            }
            flashclipboard.innerHTML = '<embed src="clipboard.swf" FlashVars="clipboard='+encodeURIComponent(content)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
        }
    }
}

	</script>
	<style type="text/css">
#log_res {
	overflow: auto;
}
 
#log_res.ajax-loading {
	padding: 20px 0;
	background: url(spinner.gif) no-repeat;
}
	</style>
<?php
}
?>
</head>
<body>

<div id="conteneur">

<div id="header">

<div id="col1">
<h1><a href="<?php echo $baseurl; ?>"><?php echo $nameblog; ?></a></h1>
<p class="baseline"><?php echo $baseline; ?></p>
</div>

<?php
include('../includes/pub.php');
?>

</div>

<div id="menu">
<?php
include('../includes/menu.php');
?>
</div>

<div id="blog">

<h2>Transformation de texte</h2>
<noscript>
<p>Vous avez javascript désactivé.<br />
Pour une transformation de texte plus rapide (utilisation d'AJAX), vous pouvez <a href="index.php">cliquer ici</a> (une fois) AVANT de l'activer.
</p></noscript>

<?php
if($phrase)
{
$dest = 'index';
}
else{
$dest = 'form';
}
?>


<form id="form" name="form" action="<?php echo $dest; ?>.php" method="get">
			
			<p>
			Phrase :
			<input type="text" size="70" name="phrase" value="<?php echo $phrase; ?>" />
			<input type="submit" name="button" value="Transformer" />
</form>
<?php
if($phrase)
{
$fr = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j","k", "l", "m", "n", "o", "p", "q", "r", "s", "t","u", "v", "w", "x", "y", "z", "?", "*", "<", ">");
$weird = array("α", "в", "¢", "∂", "є", "f", "g", "н", "ι", "נ","к", "ℓ", "м", "и", "σ", "ρ", "q", "я", "ѕ", "т","υ", "ν", "ω", "χ", "у", "z", "؟", "●", "«", "»");
$haxor = array("4","8","(","d","3","f","9","h","!","j","k","1","m","n","0","p","q","r","5","7","u","v","w","x","y","2","?"*"<",">");

function trans($from, $to, $phrase)
{
return str_ireplace($from, $to, $phrase);
}

function altern($phrase)
{
$phrase = strtolower(trim($phrase));

for($i=0;$i<strlen($phrase);$i++)
{
if($i%2 == 0)
$phrase[$i] =strtoupper($phrase[$i]);
}
return $phrase;
}

$weird = trans($fr, $weird, $phrase);
$haxor = trans($fr, $haxor, $phrase);
$alter = altern($phrase);

?>
<div id="log">
<h3>Traduction</h3>
<p>
Weird : <input type="text" size="70" value="<?php echo $weird; ?>" />
<br />
Haxor : <input type="text" size="70" value="<?php echo $haxor; ?>" />
<br />
Alter : <input type="text" size="70" value="<?php echo $alter; ?>" />
</p>
</div>

<?php
}
else{
?>
<div id="log_res"><!-- Résultat --></div>
<?php	
}
?>


<p>Générateur proposé par <a href="http://anothertime.skyrock.com">Anothertime</a>.</p>

</div>

<div id="sidebar-box">

<div id="sidebar">
<?php //include('../includes/sidebar_content.php'); ?> </div>

</div>

</div>
</body>
</html>